 {layout name="main"/}
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-3">
            <div class="ibox float-e-margins">
                <div class="ibox-content mailbox-content">
                    <div class="file-manager">
                        <a class="btn btn-block btn-primary compose-mail" href="{:url('admin/Mail/write')}">写信</a>
                        <div class="space-25"></div>
                        <h5>文件夹</h5>
                        <ul class="folder-list m-b-md" style="padding: 0">
                            <li>
                                <a href="{:url('admin/Mail/box',['usebox'=>'inbox'])}"> <i class="fa fa-inbox "></i> 收件箱 {if condition="$unread>0"}<span class="label label-warning pull-right">{$unread}</span>{/if}

                                </a>
                            </li>
                            <li>
                                <a href="{:url('admin/Mail/box',['usebox'=>'outbox'])}"> <i class="fa fa-envelope-o"></i> 发件箱</a>
                            </li>
                        </ul>
                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-9 animated fadeInRight">
            <div class="mail-box-header">
                <div class="pull-right tooltip-demo">
                    {if condition="$inbox"}
                    <a href="{:url('admin/Mail/write',['target_user_id'=>$mail->target_user_id])}" class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="回复"><i class="fa fa-reply"></i> 回复</a>
                    {/if}
                    <button onclick="del()" class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-trash-o"></i> </button>
                </div>
                <h2>
                查看邮件
            </h2>
                <div class="mail-tools tooltip-demo m-t-md">


                    <h3>
                    <span class="font-noraml">主题： </span>{$mail->title}
                </h3>
                    <h5>
                    <span class="pull-right font-noraml">{$mail->send_time}</span>
                    <span class="font-noraml">发件人： </span>{$mail->send_user->user_name}
                    {if condition="$mail->mail_type=='reply'"}<br /><span class="font-noraml">收件人： </span>{$mail->target_user->user_name}{/if}
                </h5>
                </div>
            </div>
            <div class="mail-box">


                <div class="mail-body">
                    {$mail->content}
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>
</div>

<script>
    function del() {
      if(confirm("您是否确认删除?"))
      {
        post({
            url: "{:url('admin/Mail/del',['mail_id'=>$mail->mail_id])}",
            success: function(res) {
                swal({
                    title: 'success',
                    text: res.message,
                    type: "success"
                }, function() {
                    toUrl("{:url('admin/Mail/box',['usebox'=>$mail->mail_type=='reply'?'outbox':'inbox'])}");
                });
            },
            error: function(error) {
                swal("错误", JSON.parse(error.responseText).message, "error");
            }
        });
      }

      }
</script>
